package com.situ.edu.service.impl;

import com.situ.edu.dao.IXiStudentDao;
import com.situ.edu.dao.impl.XiStudentDaoImpl;
import com.situ.edu.pojo.entity.Student;
import com.situ.edu.pojo.query.StudentQuery;
import com.situ.edu.pojo.vo.StudentVO;
import com.situ.edu.service.IXiStudentService;
import com.situ.edu.util.PageInfo;

import java.util.List;

public class XiStudentServiceImpl implements IXiStudentService {
    private IXiStudentDao studentDao = new XiStudentDaoImpl();

    @Override
    public PageInfo selectByPage(StudentQuery stuQuery) {

        List<StudentVO> list = studentDao.selectByPage(stuQuery);
        int totalCount = studentDao.selectTotalCount(stuQuery);

        return PageInfo.ok(totalCount,list);

    }

    @Override
    public void updateStatus(int id, int status) {
        studentDao.updateStatus(id,status);
    }

    @Override
    public void deleteById(int id) {
        studentDao.deleteById(id);
    }

    @Override
    public void deleteAll(String[] ids) {
        for (String id : ids) {
            studentDao.deleteById(Integer.parseInt(id));
        }
    }

    @Override
    public void add(Student student) {
        studentDao.add(student);
    }

    @Override
    public Student selectById(int id) {
        return studentDao.selectById(id);
    }

    @Override
    public void update(Student student) {
        studentDao.update(student);
    }

    //教师管理：学生请假
    @Override
    public PageInfo selectPage(StudentQuery stuQuery) {
        List<StudentVO> list = studentDao.selectPage(stuQuery);
        int totalCount = studentDao.selectTotalCo(stuQuery);

        return PageInfo.ok(totalCount,list);
    }


}
